cmake_minimum_required(VERSION 3.0.0)
project(cotask VERSION 0.1.0)
SET( CMAKE_VERBOSE_MAKEFILE on )

ENABLE_LANGUAGE(ASM)

# Detect the operating system arch
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
    set(ARCH x86_64)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
    set(ARCH x86_64)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
    set(ARCH i386)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
    set(ARCH i386)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
    set(ARCH arm64)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
    set(ARCH arm64)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
    set(ARCH arm)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
    set(ARCH arm)
else()
    message(FATAL_ERROR "${CMAKE_SYSTEM_PROCESSOR} is not supported.")
endif()


set (SRC ${PROJECT_SOURCE_DIR}/src)
add_library(
    cotask
    STATIC 
    ${SRC}/cotask.c 
    ${SRC}/arch/${ARCH}/switch.S
)
include_directories(${SRC}/arch/${ARCH})

#set(CMAKE_C_FLAGS "-fsanitize=address -fsanitize=leak -fno-omit-frame-pointer -static-libsan")
link_libraries(cotask)
add_executable(main main.c)

